GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Upload   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 78
Duplicated Lines 35.9 %

Importance

Changes 0
Metric Value
eloc 52
dl 28
loc 78
rs 10
c 0
b 0
f 0
wmc 13

3 Functions

Rating   Name   Duplication   Size   Complexity  
A initDropify 0 3 1
A constructor 0 11 1
C initDropzone 28 60 11

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
/**
2
 * This file is part of the O2System Venus UI Framework package.
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 *
7
 * @author         Steeve Andrian Salim
8
 * @copyright      Copyright (c) Steeve Andrian Salim
9
 */
10
// ------------------------------------------------------------------------
11
12
import * as $ from 'jquery';
13
import * as Dropzone from 'dropzone';
14
import 'dropify/dist/js/dropify'
15
/**
16
 * Class Upload
17
 *
18
 * @author          Teguh Rianto
19
 * @package         Components
20
 */
21
22
export default class Upload {
23
    constructor() {
24
        /**
25
         * Init dropzone
26
         */
27
        this.initDropzone();
28
29
        /**
30
         * Init dropify
31
         */
32
        this.initDropify();
33
    }
34
35
    initDropzone() {
36
        if (typeof Dropzone != 'undefined') {
37
            var urlAction = $('[name="dropzone-url"]').val();
38
39
            var previewNode = $('#dropzone-preview');
40
            previewNode.removeAttr('id');
41
            var previewTemplate = previewNode.parent().html();
42
            previewNode.parent().remove();
43
44
            var mediaDropzone = $(".dropzone-form").dropzone({
45
                url: urlAction,
46
                autoProcessQueue: true,
47
                thumbnailWidth: null,
48
                thumbnailHeight: null,
49
                previewTemplate: previewTemplate, // Define the container to display the previews
50
                //clickable: ".fileinput-button", // Define the element that should be used as click trigger to select files.
51
             });
52
53 View Code Duplication
            mediaDropzone.on("addedfile", function (file) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
54
                var fileId = 'media' + document.querySelectorAll('.media-list-item').length;
55
                file.previewElement.getElementsByTagName('input')[0].setAttribute('id', fileId);
56
                file.previewElement.getElementsByTagName('label')[0].setAttribute('for', fileId);
57
58
                var imagesFileTypes = ['image/png', 'image/jpg', 'image/jpeg', 'image/gif'];
59
                if (imagesFileTypes.indexOf(file.type) != -1) {
60
                    file.previewElement.querySelector('.media-item-file-details').style.display = 'none';
61
                } else if (file.type === 'application/pdf') {
62
                    file.previewElement.querySelector('.media-item-file-details').style.display = 'block';
63
                    file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-pdf"></i>';
64
                } else if (file.type === 'application/doc' | 'application/docx') {
0 ignored issues
show
introduced by
You have used a bitwise operator | in a condition. Did you maybe want to use the logical operator ||
Loading history...
65
                    file.previewElement.querySelector('.media-item-file-details').style.display = 'block';
66
                    file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-word"></i>';
67
                } else if (file.type === 'application/ppt' | 'application/pptx') {
68
                    file.previewElement.querySelector('.media-item-file-details').style.display = 'block';
69
                    file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-powerpoint"></i>';
70
                } else if (file.type === 'video/mp4' | 'video/webm' | 'video/mkv') {
71
                    file.previewElement.querySelector('.media-item-file-details').style.display = 'block';
72
                    file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-video"></i>';
73
                } else if (file.type === 'audio/mpeg') {
74
                    file.previewElement.querySelector('.media-item-file-details').style.display = 'block';
75
                    file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file-audio"></i>';
76
                } else {
77
                    file.previewElement.querySelector('.media-item-file-details').style.display = 'block';
78
                    file.previewElement.querySelector('.media-item-icon').innerHTML = '<i class="fas fa-file"></i>';
79
                }
80
            });
81
82
            mediaDropzone.on("success", function (file, resp) {
0 ignored issues
show
Unused Code introduced by
The parameter resp is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
83
                file.previewElement.querySelector(".media-list-item").classList.remove('uploading');
84
                file.previewElement.querySelector(".upload-progress").style.display = 'none';
85
                file.previewElement.querySelector(".media-item-file-extension").innerHTML = file.type;
86
            });
87
88
            mediaDropzone.on("error", function (file) {
89
                file.previewElement.querySelector(".media-list-item").classList.remove('uploading');
90
                file.previewElement.querySelector(".upload-progress").style.display = 'none';
91
                file.previewElement.querySelector(".media-item-file-extension").innerHTML = file.type;
92
            });
93
        }
94
    }
95
96
    initDropify(){
97
        $('.dropify').dropify();
98
    }
99
}